package com.neuedu.corejava.ch10;
import java.util.Deque;
import java.util.LinkedList;

public class LinkedListClass {

	public static void main(String[] args) {
		// LinkedList类实现了种数据结构
		//实现了（双端）链接结构，队列，栈
		
		//队列结构
		//队列结构具有先进先出，后进后出
		//LinkedList<Computer> linkedList=new LinkedList<Computer> ();
		Deque<Computer> linkedList=new LinkedList<Computer> ();
		linkedList.addLast(new Computer("HP1",5000));
		linkedList.addLast(new Computer("HP2",5000));
		linkedList.addLast(new Computer("HP3",5000));
		linkedList.addLast(new Computer("HP4",5000));
		linkedList.addLast(new Computer("HP5",5000));
		linkedList.addLast(new Computer("HP6",5000));
		linkedList.addLast(new Computer("HP7",5000));
		linkedList.addLast(new Computer("HP7",5000));
		linkedList.addLast(new Computer("HP8",5000));
		
		Computer computer=null;
		while((computer = linkedList.pollFirst()) != null) {
			System.out.println(computer);
		}
		
		//双端队列
		linkedList.addFirst(new Computer("HP1",5000));
		linkedList.addFirst(new Computer("HP2",5000));
		linkedList.addFirst(new Computer("HP3",5000));
		linkedList.addFirst(new Computer("HP4",5000));
		linkedList.addFirst(new Computer("HP5",5000));
		linkedList.addFirst(new Computer("HP6",5000));
		linkedList.addFirst(new Computer("HP7",5000));
		linkedList.addFirst(new Computer("HP7",5000));
		linkedList.addFirst(new Computer("HP8",5000));
		
		while((computer = linkedList.pollFirst()) != null) {
			System.out.println(computer);
		}
		

	}

}
